#ifndef DTWENTYITEMCONTAINER_H
#define DTWENTYITEMCONTAINER_H

#include "dtwenty_global.h"
#include "dtwentyitem.h"


class DTWENTYSHARED_EXPORT DTwentyItemContainer : public DTwentyItem
{
    Q_OBJECT

    class Data : public QSharedData
    {
    public:
        Data()
        {
            childType = -1;
        }

        Data(const Data& other) : QSharedData(other)
        {
            childType = other.childType;
            valueSource = other.valueSource;
        }

        int childType;
        QPointer<DTwentyItemContainer> valueSource;

    };

public:

    Q_INVOKABLE DTwentyItemContainer(QObject* parent = 0);

    DTwentyItemContainer(const DTwentyItemContainer& other);

    virtual int type() const;


    virtual bool removable() const;

    int childType() const;

    QString childTypeName() const;

    DTwentyItem* newChild(const QString& name = QString());

    virtual QVariantMap valueOptions() const;

    DTwentyItemContainer *valueSource() const;
    void setValueSource(DTwentyItemContainer *valueSource);


protected:

    template<typename CHILD_CLASS>
    void registerChildType()
    {
        d->childType = qRegisterMetaType<CHILD_CLASS*>();
    }


private:

    QSharedDataPointer<Data> d;

};


Q_DECLARE_METATYPE(DTwentyItemContainer)


#endif // DTWENTYITEMCONTAINER_H


